//
//  BaseViewController.m
//  TradeCloud
//
//  Created by zhangming on 2018/3/26.
//  Copyright © 2018年 zhangming. All rights reserved.
//

#import "BaseViewController.h"
#import "UIView+Toast.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

//侧滑
//- (void)viewWillAppear:(BOOL)animated{
//
//    [super viewWillAppear:animated];
//
//    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //解决设置导航栏不透明后界面下移问题
    //self.extendedLayoutIncludesOpaqueBars = YES;
    [self setAutomaticallyAdjustsScrollViewInsets:NO];
    
    self.view.backgroundColor = BASECOLOR;
    
}

#pragma mark - 带返回的navBar
- (void)setNavBarWithTitle:(NSString *)title
{
    self.title = title;
//    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageName:@"icon_back_normal" selectedImageName:@"icon_back_normal" target:self action:@selector(back)];
//    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
    
    UIButton *settingButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //修改按钮向左偏移10 point
    [settingButton setFrame:CGRectMake(-18.0, 0.0, 44.0, 44.0)];
    [settingButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [settingButton setImage:[UIImage imageNamed:@"返回icon"] forState:UIControlStateNormal];
    //修改方法
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 44.0, 44.0)];
    [view addSubview:settingButton];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:view];
    
    self.navigationItem.leftBarButtonItem = rightItem;
    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
}

- (void)back{
    
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - MBProgress展示错误信息
- (void)showMBPError:(NSString *)msg{
    
    [self.view makeToast:msg duration:2.0 position:CSToastPositionCenter];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - DZNEmptyDataSetDelegate
- (UIImage *)buttonImageForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state
{
    return [UIImage imageNamed:@"img_null"];
}

#pragma mark - 跳转建设页面
- (void)goNotVCWithTitle:(NSString *)title{
    
    NotOkViewController *VC = [[NotOkViewController alloc] init];
    VC.theTitle = title;
    [self.navigationController pushViewController:VC animated:YES];
}

@end
